package cn.edu.ustc.xrovers.action;

import cn.edu.ustc.xrovers.dto.PageBean;
import cn.edu.ustc.xrovers.service.BaseService;
import cn.edu.ustc.xrovers.service.PaginationService;
import com.opensymphony.xwork2.ActionSupport;

public class LoanPaginationAction extends ActionSupport{
	
	private static final int PAGESIZE=10;
	private int currentPage;
	private PaginationService pagination;
	private BaseService bs;
	private PageBean page0;
	private PageBean page1;
	
	/**
	 * 已分析贷款分页支持
	 * @return "analyzedLoan"
	 * @throws Exception
	 */
	public String findAnalyzedLoan() throws Exception {
		String hql=bs.getLoanHql(true);
		page1=pagination.queryForPage(hql, PAGESIZE, currentPage);
		return "analyzedLoan";
	}
	
	/**
	 * 未分析贷款分页支持
	 * @return "unAnalyzedLoan"
	 * @throws Exception
	 */
	public String findUnAnalyzedLoan() throws Exception{
		String hql=bs.getLoanHql(false);
		page0=pagination.queryForPage(hql, PAGESIZE, currentPage);
		return "unAnalyzedLoan";
	}
	
	/**
	 * 查询未分析和已分析的贷款项
	 * @return "success"
	 * @throws Exception
	 */
	public String findLoans() throws Exception {
		String hql0=bs.getLoanHql(false);
		String hql1=bs.getLoanHql(true);
		page0=pagination.queryForPage(hql0, PAGESIZE, currentPage);
		page1=pagination.queryForPage(hql1, PAGESIZE, currentPage);
		return "success";
	}
	
	/*getset方法*/
	public void setPagination(PaginationService pagination) {
		this.pagination = pagination;
	}

	public PaginationService getPagination() {
		return pagination;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setBs(BaseService bs) {
		this.bs = bs;
	}

	public BaseService getBs() {
		return bs;
	}

	public void setPage0(PageBean page0) {
		this.page0 = page0;
	}

	public PageBean getPage0() {
		return page0;
	}

	public void setPage1(PageBean page1) {
		this.page1 = page1;
	}

	public PageBean getPage1() {
		return page1;
	}
}
